// pages/master/mainten/mainten.js
const app = getApp()
const db = wx.cloud.database()
const _ = db.command
const UsertoTuina=db.collection('UsertoTuina')
const OrderData=db.collection('OrderData')
Page({

  /**
   * 页面的初始数据
   */
  data: {
      order_now:null,
      haveorder:true
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    let that = this
    UsertoTuina.where({
      staffID:app.userDate.userInfo.userPhone
    })
    .get({
      success: function(res) {
        let tuinaID= res.data[0].TuinaID
        console.log(tuinaID)
        OrderData.where({
          OrderID:tuinaID,
          isweihu:false
        })
        .get({
          success: function(res) {
           console.log(res.data[0])
           if(res.data.length>0){
            that.setData({
              order_now:res.data[0],
              haveorder:false
            })}
          }
        })
   
      }
    })
  },
  clickVIPBusiness:function(){
      wx.navigateTo({
        url: '../mainten/clickVIPBusiness/clickVIPBusiness',
      })
  },
  clickSearch:function(e){
    let num =e.detail.value.famNum
    if(num==''){
      wx.showToast({
        title: '请输入家庭编号',
        icon:'none'
      })
    }else{
      wx.navigateTo({
        url: './famMainten/famMainten?num='+num,
      })
    }
  },


  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    wx.hideTabBar({
      success: function () {
        app.onTabBar('staff');
      }
    })
  },
  onReady: function () {
  },
  onPullDownRefresh: function () {
      this.onLoad()
  },
})